  carrierTaskRun=(function  (){
  	         speed=0.05
  	         correction=30;//修正时间 
				   	 var taskRunStatus={};
				   	 
				   	  function getAnchor(taskNo){
				   	 	    var runStatus=taskRunStatus[taskNo];
				   	 	    ++runStatus.time;//行走距离
				   	 	    ++runStatus.time1;//执行时间
						   	  var beginAnchor =runStatus.beginAnchor;
					        var endAnchor = runStatus.endAnchor;
						   	  var corren= {x:beginAnchor.x+runStatus.move.x*runStatus.time*speed,y:beginAnchor.y+runStatus.move.y*runStatus.time*speed}
						   	 
						   	
					       if(runStatus.move.x!=0&&(corren.x-endAnchor.x)*(corren.x-beginAnchor.x)>=0||runStatus.move.y!=0&&(corren.y-endAnchor.y)*(corren.y-beginAnchor.y)>=0){
					        	runStatus.time--;
					       }
					       
					       var forword=false;//是否超前
					       if(runStatus.currentPos){
					       	  var defX = corren.x-runStatus.currentPos.x;
					       	  var defY = corren.y-runStatus.currentPos.y;
					       	}
					       if(parseInt(defX)*runStatus.move.x<0||parseInt(defY)*runStatus.move.y<0){
					       	   		forword=true;//超前
					       }else{
					       	forword=forword;
					       	}
					       if(runStatus.currentPos&&runStatus.time1<correction){//以前有定位且与当前位置不重合，主要考虑数据不精确引起的，定位异常。
					       	  
					       	   
					       	   if(!runStatus.normal){//非正常路径前行
					       	   	   defX =defX/(correction-runStatus.time1)
					       	   		 defY =defY/(correction-runStatus.time1)
					       	  		 runStatus.currentPos.x+=defX;
					       	   		 runStatus.currentPos.y+=defY;
					       	   	}else if(!forword){
					       	   		 runStatus.currentPos=corren
					       	   	}
					       	   	
					       	
					       }else{
					       	if(!runStatus.currentPos||!forword){
					       		 runStatus.currentPos=corren;
					       		}
					       	  
					       	}
					    
					       return runStatus.currentPos
				   	 	
				   	 }
				   	 
				   	 function initTaskRunStatus(res,beginCarrier,endCarrier){
			   	 	          var beginAnchor =  beginCarrier.getAnchor();
							        var beginWidth = beginCarrier.length;
							        var endAnchor = endCarrier.getAnchor();
							        var endWidth = endCarrier.length;
								      res.beginAnchor=beginAnchor
									    res.endAnchor=endAnchor
									    var isSp=false;//水平行走
									    if(Math.abs(beginAnchor.x-endAnchor.x) >Math.abs(beginAnchor.y-endAnchor.y)){
									    	isSp=true;
									    }
								      
			
										  if(isSp){//水平行走
										      if(beginAnchor.x>endAnchor.x){
									      			res.move={x:-1,y:0}
									      			//res.beginAnchor.x+=beginWidth/2
									      			//res.endAnchor.x-=endWidth/2
									        }else{
									        		res.move={x:1,y:0}
									        	  //res.beginAnchor.x-=beginWidth/2
									        	 // res.endAnchor.x+=endWidth/2
									        }
								      }else {//垂直行走
								      	  if(beginAnchor.y>endAnchor.y){
									      		 res.move={x:0,y:-1}
									      		 //res.beginAnchor.y+=beginWidth/2
									      		 //res.endAnchor.y-=endWidth/2
									        }else{
									        	 res.move={x:0,y:1}
									        	// res.beginAnchor.y-=beginWidth/2
									        	 //res.endAnchor.y+=endWidth/2
									        }
								      }
								     // res.beginAnchor.x+=res.move.x*stockSize/2;
								     // res.beginAnchor.y+=res.move.y*stockSize/2;
								      //res.endAnchor.x-=res.move.x*stockSize/2;
								      //res.endAnchor.y-=res.move.y*stockSize/2;
								      return res;
				   	 	
				   	 	}
  return  new  function(){
  	
					  	this.getPath=function(taskNo){
					  		
					  		if(taskRunStatus.hasOwnProperty(taskNo)){
					   	 			return taskRunStatus[taskNo]
					   	   }
					   	   return null;
					  		}
			    	
				   	 this.updateTask=function(taskNo,begin,end){
				   	 	
				   	 	//console.log(taskNo,"->",begin,":",end)
					   	 if(!taskRunStatus.hasOwnProperty(taskNo)){
					   	 			taskRunStatus[taskNo]={}
					   	 }
					   	 
					   	 var runStatus=taskRunStatus[taskNo];
					   	 		 runStatus.perClear=0;
					   	 if(begin==end&&begin==taskRunStatus[taskNo].endPath&&begin!=taskRunStatus[taskNo].beginPath){
					   	 
					   	 	   return;
					   	 }
					   	 if(taskRunStatus[taskNo].beginPath!=begin||taskRunStatus[taskNo].endPath!=end){
					   	 	
						   	 		if(begin==runStatus.endPath){
						   	 			runStatus.normal=true
						   	 		}else{
						   	 			runStatus.normal=false
						   	 		}
						   	 		runStatus.beginPath=begin;
						   	 		runStatus.endPath=end;
						   	 		runStatus.time=0;
						   	 		runStatus.time1=0;
						   	 		var beginCarrier={}
						   	 	  var endCarrier={}
						   	 		for(var i=0;i<allPath.length;i++){
									     	 var carrier=		allPath[i]
							     			 if(carrier.id==begin){
							     			 	  beginCarrier = carrier
							     			 }
							     			  if(carrier.id==end){
							     			 	  endCarrier = carrier
							     			 }
							     			 if(beginCarrier.id&&endCarrier.id){
							     			 		break;
							     			 }
							      }
						   	 		initTaskRunStatus(runStatus,beginCarrier,endCarrier)
						   	 		
						   	 		
					   	 }
				   	 }
				 	 this.perClear=function(){
				   	for(var taskNo in taskRunStatus){
				   		taskRunStatus[taskNo].perClear=1;
				   	}
				 	 }
				   	 
				   	 
				   	 this.myClear=function(){
						   	for(var key in taskRunStatus){
						   			if(taskRunStatus[key].perClear==1){
						   					delete taskRunStatus[key]
						   			}
						   	}
				   	 }
				   	 
				   	 this.getAllAnthor=function(){
				   	 	var array=[];
				   	 	for(var taskNo in taskRunStatus){
					   	 		var dat=getAnchor(taskNo);
					   	 		array.push(dat)
				   	 	}
				   	 	return array;
				   	 }
				   	 
				   	
	   	 }
	   	 
   	}())
   	
   	
   	
   	
   	graph =(new function () {
		
    //存储顶点
    var vertices = {};
	 //边
    var adjList = {};
    //添加顶点的方法。
    function addVertices(v) {
    	if(vertices[v]==undefined){
    			vertices[v]={deep:0,befort:""};
    	}
    
    };
    
     this.addVector = function (v,w) {
	    	addVertices(v);
	    	addVertices(w);
	    	if(adjList[v]== undefined){
	    		adjList[v]=[];
	    	}
	    	adjList[v].push(w)
    };
    this.addEdge = function (v,w) {
	    	this.addVector(v,w);
	    	this.addVector(w,v);
    };
 
  
		this.baseDistance=function(from ,to){
			initPath();
			vertices[from].deep=0
			scan(from ,1);
			var res=[]
			if(vertices[to].deep==-1){
				return res;
			}
				res.push(to)
			while(vertices[to].befort&&vertices[to].befort!=from){
				res.push(vertices[to].befort);
				to=vertices[to].befort
			}
			res.push(from)
			return res;
			
		}
		
	 function initPath(){
	 	  for(var k in vertices){
	 			vertices[k].deep=-1
	 			vertices[k].befort="";
	 		}
   }
		function scan(from ,deep){
			var arr = adjList[from];//所有边
			if(!arr){
				return;
			}
			for(var i=0;i<arr.length;i++){//关联点
				  var v=vertices[arr[i]]
					if(v.deep==-1||v.deep>deep){
						v.deep=deep
						v.befort=from;
						scan(arr[i],deep++)
					}
				
			}
		
		}
}());
   
   
   
   
   